<?php
require_once('lib/constants.php');
require_once('lib/menu.php');

?>
<script src="pages_admin/menus/_menus.js" type="text/javascript"></script>
<div id="menus_ajouter">
<h3>Ajouter un <span>menu</span></h3>
	<form method="post" action="pages_admin/ajax_admin.php">
		<p>
			<label for="type">Type de l'élément à ajouter :</label>
			<select id="type">
				<option value="-1"></option>
				<option value="bloc">Bloc</option>
				<option value="menu">Menu</option>
			</select>
		</p>
		<div class="ajax"></div>
		<div id="bloc" class="hidden" style="background:#EFF5FF; border:1px solid #3B5F9F;">
				<p>
					<label>Nom :</label><br />
					<input type="text" name="name" size="50" />
				</p>
				<p>
					<label>Icone :</label><br />
					<input type="text" name="image" size="30" disabled="disabled" />&nbsp;&nbsp;<span id="selected_icon"></span>
					<div id="icons_list">
						<?php
						$icons = glob('images/icons/*');
						foreach($icons as $icon) {
							echo '<img src="'.$icon.'" alt="'.basename($icon).'" />';
						}
						?>
					</div>
					
				</p>
				<p>
					<input type="submit" name="bloc_add" id="bloc_add" class="record" value="Enregistrer" />
				</p>
		</div>
		
		<div id="menu" class="hidden" style="background:#FFFCDF; border:1px solid #AFA320;">
				<p>
					<label>Nom :</label><br />
					<input type="text" name="name" />
				</p>
				<p>
					<label>Bloc associé :</label><br />
					<select name="section">
						<?php
						$sections = menu_get_all_blocs();
						while($section = mysql_fetch_assoc($sections)) {
							if ($section['id'] == ESPACE_ADH_CONNECT || $section['id'] == ESPACE_ADH_NOT_CONNECT) {
								continue; // ignore les menus "espace adhérent" pour qu'il ne soient pas modifiables
							}
							echo '<option value="'.$section['id'].'">'.$section['name'].'</option>';
						}
						?>
					</select>
				</p>
				<p>
					<input type="submit" name="menu_add" id="menu_add" class="record" value="Enregistrer" />
				</p>
		</div>
	</form>
</div>